package com.jeecms.wicool.dao.share.impl;

import com.jeecms.common.hibernate3.HibernateBaseDao;
import com.jeecms.wicool.dao.share.PraiseDao;
import com.jeecms.wicool.entity.share.Praise;
import org.springframework.stereotype.Repository;

/**
 * Created by cuiyanlei on 15/6/17.
 */
@Repository
public class PraiseDaoImpl extends HibernateBaseDao<Praise,Integer> implements PraiseDao {

    @Override
    protected Class<Praise> getEntityClass() {
        return Praise.class;
    }

    @Override
    public Praise findById(Integer foreginKey, int type) {
        return (Praise) super.findUnique(" select bean from Praise bean where bean.pid=? and bean.type=?", foreginKey, type);
    }

    @Override
    public Praise deleteByForeginKey(Integer foreginKey, int type) {
        Praise bean = findById(foreginKey, type);
        if (null != bean) {
            getSession().delete(bean);
        }
        return bean;
    }

    @Override
    public Praise save(Praise praise) {
        getSession().save(praise);
        return praise;
    }
}
